package com.ptu.controller.admin;

import com.github.pagehelper.PageInfo;
import com.ptu.context.BaseContext;
import com.ptu.dto.CommentDTO;
import com.ptu.dto.CommentPageQueryDTO;
import com.ptu.dto.DishDTO;
import com.ptu.entity.Comment;
import com.ptu.result.PageResult;
import com.ptu.result.Result;
import com.ptu.service.CommentService;
import com.ptu.vo.CommentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/comment")
@Api(tags = "评论相关接口")
@Slf4j
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/page")
    public Result<PageResult> page(CommentPageQueryDTO commentPageQueryDTO) {
        log.info("评论分页查询：{}", commentPageQueryDTO);
        commentPageQueryDTO.setStoreId(BaseContext.getCurrentId());
        PageResult pageResult = commentService.pageQuery(commentPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 回复评论
     * @param commentDTO
     * @return
     */

    @PutMapping
    @ApiOperation("修改评论")
    public Result update(@RequestBody CommentDTO commentDTO){
        log.info("修改评论：{}", commentDTO);
        commentService.update(commentDTO);
        return Result.success();
    }
}